<?php

require_once 'Component.php';

class ComponentArray extends Component{

    private $components = array();

    public function addComponent($component){
        //if(in_array($component, $this->components))
        $this->components[] = $component;
    }

    public function initialize(){
        foreach($this->components as $component)
            if($component->isEnabled())
                $component->initialize();
    }

    public function processRequest(){
        foreach($this->components as $component)
            if($component->isEnabled())
                $component->processRequest();

    }

    public function createOutput(){
        $output = array();
        foreach($this->components as $component)
            if($component->isEnabled())
                $output[] = $component->createOutput();
        return $output;
    }

    public function setOwner(Container $owner){
        parent::setOwner($owner);
         foreach($this->components as $component)
            $component->setOwner($owner);
    }

}
?>
